package research.report.datasource;

import java.util.List;

import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;

public class ParametersDatasource implements JRDataSource
{
	private List<String> data;
	private int index = -1;
	
	public ParametersDatasource(List<String> data) {
		this.data = data;
	}

	public boolean next() throws JRException {
		index++;
		return (index < data.size());
	}

	public Object getFieldValue(JRField field) throws JRException {
		Object value = null;
		
		String fieldName = field.getName();
		
		if ("name".equals(fieldName)) {
			value = data.get(index);
		}
		
		return value;
	}
}
